//
//  GroupOrderService.m
//  YYZB
//
//  Created by 信晨汇 on 2017/10/17.
//
//

#import "GroupOrderService.h"

@implementation GroupOrderService


//团购列表

- (void)GetGroupBuyCommunitiesDetailListSortType:(NSString *)sortType
                                          pageIndex:(NSNumber *)pageIndex
                                          pageSize:(NSNumber *)pageSize
                                     communityId:(NSString *)communityId
                                     groupBuyingId:(NSString *)groupBuyingId

            completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder {
    
    NSString *URL = @"GroupBuy/GetGroupBuyCommunitiesDetailList";
    
    NSDictionary *params = @{@"GroupBuyingId":groupBuyingId,
                             @"CommunityId":communityId,
                             @"SortType": sortType,
                             @"PageIndex": pageIndex,
                             @"PageSize":pageSize
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}



//团购订单列表
- (void)GetGrouponOrdersType:(NSString *)type  //订单类型 1：可用团购 2：待服务 3：团购明细
                    PageSize:(NSNumber *)pageSize
                      PageNo:(NSNumber *)pageNo
           completionHanlder:(void (^)(NSDictionary *, NSError *))completionHanlder{


    
    NSString *URL = @"GrouponOrder/GetGrouponOrders";
    NSDictionary *params = @{@"PageSize":pageSize,
                             @"PageNo":pageNo,
                             @"Type": type,
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:YES];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSDictionary  *dic = [self unboxedValue:result error:&err];
        
            
            completionHanlder(dic, err);
        }
    }];




}


@end
